<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>matrix.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
       <span class="fn">matrix.js</span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Class for representing matrices and static helper functions.
  </div>
  

        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="closure_goog_math_matrix.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
          </ol>
        </div>
</div>

<h2 class="g-first">File Location</h2>
  <div class="g-section g-tpl-20-80">
    <div class="g-unit g-first">
      <div class="g-c-cell code-label">math/matrix.js</div>
    </div>
  </div>
<hr/>


  <h2>Classes</h2>
 <div class="fn-constructor">
        <a href="class_goog_math_Matrix.html">
          goog.math.Matrix</a><br/>
        <div class="class-details">Class for representing and manipulating matrices.

The entry that lies in the i-th row and the j-th column of a matrix is
typically referred to as the i,j entry of the matrix.

The m-by-n matrix A would have its entries referred to as:
[ a0,0   a0,1   a0,2   ...   a0,j  ...  a0,n ]
[ a1,0   a1,1   a1,2   ...   a1,j  ...  a1,n ]
[ a2,0   a2,1   a2,2   ...   a2,j  ...  a2,n ]
[  .      .      .            .          .   ]
[  .      .      .            .          .   ]
[  .      .      .            .          .   ]
[ ai,0   ai,1   ai,2   ...   ai,j  ...  ai,n ]
[  .      .      .            .          .   ]
[  .      .      .            .          .   ]
[  .      .      .            .          .   ]
[ am,0   am,1   am,2   ...   am,j  ...  am,n ]</div>
 </div>
      
<br/>

  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>


  <h2>Global Functions</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.math.Matrix.createIdentityMatrix"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Matrix.</span><span class="entryName">createIdentityMatrix<span class="args">(<span class="arg">n</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_math_Matrix.html">goog.math.Matrix</a></span></div>
      </div>


     <div class="entryOverview">
       Creates a square identity matrix. i.e. for n = 3:
<pre class="lang-js">
[ 1 0 0 ]
[ 0 1 0 ]
[ 0 0 1 ]
</pre>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">n</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">The size of the square identity matrix.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_math_Matrix.html">goog.math.Matrix</a></span></div>&nbsp;
            Identity matrix of width and height {@code n}.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_math_matrix.js.source.html#line81">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.math.Matrix.createZeroPaddedArray_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Matrix.</span><span class="entryName">createZeroPaddedArray_<span class="args">(<span class="arg">m</span>,&nbsp;<span class="arg">n</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&gt;&gt;</div>
      </div>


     <div class="entryOverview">
       Creates a new zero padded matix.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">m</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">Height of matrix.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">n</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">Width of matrix.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&gt;&gt;</div>&nbsp;
            The new zero padded matrix.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_math_matrix.js.source.html#line164">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.math.Matrix.forEach"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Matrix.</span><span class="entryName">forEach<span class="args">(<span class="arg">matrix</span>,&nbsp;<span class="arg">fn</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Calls a function for each cell in a matrix.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">matrix</span>
        : <div class="fullType"><span class="type"><a href="class_goog_math_Matrix.html">goog.math.Matrix</a></span></div>
        <div class="entryOverview">The matrix to iterate over.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">fn</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>
        <div class="entryOverview">The function to call for every element. This function takes 4 arguments (value, i, j, and the matrix) and the return value is irrelevant.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
        <div class="entryOverview">The object to be used as the value of &#39;this&#39; within {@code fn}.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_math_matrix.js.source.html#line102">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.math.Matrix.isValidArray"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Matrix.</span><span class="entryName">isValidArray<span class="args">(<span class="arg">arr</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
      </div>


     <div class="entryOverview">
       Tests whether an array is a valid matrix.  A valid array is an array of
arrays where all arrays are of the same length and all elements are numbers.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">arr</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span></div>
        <div class="entryOverview">An array to test.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>&nbsp;
            Whether the array is a valid matrix.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_math_matrix.js.source.html#line117">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.math.Matrix.map"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Matrix.</span><span class="entryName">map<span class="args">(<span class="arg">matrix</span>,&nbsp;<span class="arg">fn</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_math_Matrix.html">goog.math.Matrix</a></span></div>
      </div>


     <div class="entryOverview">
       Calls a function for every cell in a matrix and inserts the result into a
new matrix of equal dimensions.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">matrix</span>
        : <div class="fullType"><span class="type"><a href="class_goog_math_Matrix.html">goog.math.Matrix</a></span></div>
        <div class="entryOverview">The matrix to iterate over.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">fn</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>
        <div class="entryOverview">The function to call for every element. This function takes 4 arguments (value, i, j and the matrix) and should return something. The result will be inserted into a new matrix.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
        <div class="entryOverview">The object to be used as the value of &#39;this&#39; within {@code fn}.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_math_Matrix.html">goog.math.Matrix</a></span></div>&nbsp;
            A new matrix with the results from {@code fn}.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_math_matrix.js.source.html#line148">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>






      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Directory math</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">File Reference</h2>
            <div id="sideFileIndex" rootPath="closure/goog" current="math/matrix.js"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
